home *** CD-ROM | disk | FTP | other *** search
/ Sound Fx / Sound Fx.iso / Software / UNZIPED / DWSTK / ERR.C < prev    next >
C/C++ Source or Header  |  1996-10-10  |  12KB  |  385 lines

  1. /******************************************************************************
  2. File:          err.c
  3. Version:     2.22
  4. Tab stops: every 2 columns
  5. Project:     any STK related code
  6. Copyright: 1994-1995 DiamondWare, Ltd.    All rights reserved.*
  7. Written:     Keith Weiner & Erik Lorenzen
  8. Purpose:     contains a routine to handle any error generated by the STK
  9. History:     94/10/21 KW Started
  10.                      95/02/21 EL Finalized for 1.00
  11.                      95/03/18 EL Added new error to err_Display(), dws_BUSY
  12.                      95/03/22 EL Finalized for 1.01
  13.                      95/04/06 EL Added new error to err_Display(), dws_IRQDISABLED
  14.                      95/04/11 EL moved DisplayError to err.c (err_Display).
  15.                      95/04/12 EL Finalized for 1.02
  16.                      95/06/16 EL Finalized for 1.03
  17.                      95/07/02 EL Added new errors dws_NOMEM & dws_NOTRESIDENT
  18.                      95/07/23 EL Finalized for 2.00, added a getch()
  19.                      95/07/23 EL Finalized for 2.00, added a getch()
  20.                      95/09/22 EL Changed some comments, added modual support,
  21.                                              and #if's for __FLAT__ model
  22.                      95/10/05 EL Finalized for 2.10
  23.                      95/10/18 EL Finalized for 2.20, no changes
  24.                      95/12/10 EL Finalized for 2.21, fixed #if #endif to exclude default
  25.                      96/10/10 EL Finalized for 2.22, no changes
  26. Notes
  27. -----
  28. *Permission is expressely granted to use err_Display or any derivitive made
  29.  from it to registered users of the STK.
  30. ******************************************************************************/
  31.  
  32.  
  33.  
  34. #include <conio.h>
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37.  
  38. #include "err.h"
  39.  
  40.  
  41.  
  42. void err_Display(word errornum, err_MODULE module)
  43. {
  44.     switch (module)
  45.     {
  46.         case err_DWS:
  47.         {
  48.             switch (errornum)
  49.             {
  50.                 case dws_EZERO:
  51.                 {
  52.                     /*
  53.                      . This should not have happened, considering how we got here!
  54.                     */
  55.                     printf("DWS: I'm confused!  There is no error number!\n");
  56.                     break;
  57.                 }
  58.                 case dws_NOTINITTED:
  59.                 {
  60.                     /*
  61.                      . If we get here, it means you haven't called dws_Init().
  62.                      . The STK needs to initialize itself and the hardware before
  63.                      . it can do anything.
  64.                     */
  65.                     printf("DWS: The STK was not initialized\n");
  66.                     break;
  67.                 }
  68.                 case dws_ALREADYINITTED:
  69.                 {
  70.                     /*
  71.                      . If we get here, it means you've called dws_Init() already.
  72.                      . Calling dws_DetectHardWare at this point would cause zillions
  73.                      . of problems if we let the call through.
  74.                     */
  75.                     printf("DWS: The STK was already initialized\n");
  76.                     break;
  77.                 }
  78.                 case dws_NOTSUPPORTED:
  79.                 {
  80.                     /*
  81.                      . If we get here, it means that either the user's machine does not
  82.                      . support the function you just called, or the STK was told not to
  83.                      . support it in dws_Init.
  84.                     */
  85.                     printf("DWS: Function not supported\n");
  86.                     break;
  87.                 }
  88.                 case dws_DetectHardware_UNSTABLESYSTEM:
  89.                 {
  90.                     /*
  91.                      . Please report it to DiamondWare if you get here!
  92.                      .
  93.                      . Ideally, you would disable control-C here, so that the user can't
  94.                      . hit control-alt-delete, causing SmartDrive to flush its (possibly
  95.                      . currupt) buffers.
  96.                     */
  97.                     printf("DWS: The system (or DOS box) is unstable!\n");
  98.                     printf("     If not in a multitasking system, please power down!\n");
  99.  
  100.                     InfiniteLoop:
  101.                         goto InfiniteLoop;
  102.                 }
  103.  
  104.                 /*
  105.                  . The following three errors are USER/PROGRAMMER errors.  You forgot
  106.                  . to fill the cardtyp struct full of -1's (except in those fields
  107.                  . you intended to override, or the user (upon the unlikly event that
  108.                  . the STK was unable to find a card) gave you a bad overide value.
  109.                 */
  110.                 case dws_DetectHardware_BADBASEPORT:
  111.                 {
  112.                     /*
  113.                      . You set dov.baseport to a bad value, or
  114.                      . didn't fill it with a -1.
  115.                     */
  116.                     printf("DWS: Bad port address\n");
  117.                     break;
  118.                 }
  119.                 case dws_DetectHardware_BADDMA:
  120.                 {
  121.                     /*
  122.                      . You set dov.digdma to a bad value, or
  123.                      . didn't fill it with a -1.
  124.                     */
  125.                     printf("DWS: Bad DMA channel\n");
  126.                     break;
  127.                 }
  128.                 case dws_DetectHardware_BADIRQ:
  129.                 {
  130.                     /*
  131.                      . You set dov.digirq to a bad value, or
  132.                      . didn't fill it with a -1.
  133.                     */
  134.                     printf("DWS: Bad IRQ level\n");
  135.                     break;
  136.                 }
  137.                 case dws_Kill_CANTUNHOOKISR:
  138.                 {
  139.                     /*
  140.                      . The STK points the interrupt vector for the sound card's IRQ
  141.                      . to its own code in dws_Init.
  142.                      .
  143.                      . dws_Kill was unable to restore the vector to its original
  144.                      . value because other code has hooked it after the STK
  145.                      . initialized(!)  This is really bad.    Make the user get rid
  146.                      . of it and call dws_Kill again.
  147.                     */
  148.                     printf("DWS: Get rid of your TSR, pal!\n");
  149.                     break;
  150.                 }
  151.                 case dws_X_BADINPUT:
  152.                 {
  153.                     /*
  154.                      . The mixer funtions can only accept volumes between 0 & 255,
  155.                      . the volume will remain unchanged.
  156.                     */
  157.                     printf("DWS: Bad mixer level\n");
  158.                     break;
  159.                 }
  160.                 case dws_D_NOTADWD:
  161.                 {
  162.                     /*
  163.                      . You passed the STK a pointer to something which is not a .DWD file!
  164.                     */
  165.                     printf("DWS: Pointer does not point to a .DWD\n");
  166.                     break;
  167.                 }
  168.                 case dws_D_NOTSUPPORTEDVER:
  169.                 {
  170.                     /*
  171.                      . The STK can't play a .DWD converted using a version of VOC2DWD.EXE
  172.                      . newer than itself.  And, although we'll try to maintain backwards
  173.                      . compatibility, we may not be able to guarantee that newer versions
  174.                      . of the code will be able to play older .DWD files.  In any event,
  175.                      . it's a good idea to always convert .VOC files with the utility
  176.                      . which comes with the library you're linking into your application.
  177.                     */
  178.                     printf("DWS: Please reconvert this file using the VOC2DWD.EXE\n");
  179.                     printf("     which came with this library\n");
  180.                     break;
  181.                 }
  182.                 case dws_D_INTERNALERROR:
  183.                 {
  184.                     /*
  185.                      . This error should never occur and probably will not affect sound
  186.                      . play(?).  If it happens please contact DiamondWare.
  187.                     */
  188.                     printf("DWS: An internal error has occured\n");
  189.                     printf("     Please contact DiamondWare\n");
  190.                     break;
  191.                 }
  192.                 case dws_DPlay_NOSPACEFORSOUND:
  193.                 {
  194.                     /*
  195.                      . This error is more like a warning, though it may happen on a
  196.                      . regular basis, depending on how many sounds you told the STK
  197.                      . to allow in dws_Init, how you chose to prioritize sounds and
  198.                      . how many sounds are currently being played.
  199.                     */
  200.                     printf("DWS: No more room for new digitized sounds right now\n");
  201.                     break;
  202.                 }
  203.                 case dws_DSetRate_FREQTOLOW:
  204.                 {
  205.                     /*
  206.                      . The STK will set rate as close as possible to the indicated rate
  207.                      . but cannot set a rate that low.
  208.                     */
  209.                     printf("DWS: Playback frequency too low\n");
  210.                     break;
  211.                 }
  212.                 case dws_DSetRate_FREQTOHIGH:
  213.                 {
  214.                     /*
  215.                      . The STK will set rate as close as possible to the indicated rate
  216.                      . but cannot set a rate that high.
  217.                     */
  218.                     printf("DWS: Playback frequency too high\n");
  219.                     break;
  220.                 }
  221.                 case dws_MPlay_NOTADWM:
  222.                 {
  223.                     /*
  224.                      . You passed the STK a pointer to something which is not a .DWM file!
  225.                     */
  226.                     printf("DWS: Pointer does not point to a .DWM\n");
  227.                     break;
  228.                 }
  229.                 case dws_MPlay_NOTSUPPORTEDVER:
  230.                 {
  231.                     /*
  232.                      . The STK can't play a .DWM converted using a version of VOC2DWM.EXE
  233.                      . newer than itself.  And, although we'll try to maintain backwards
  234.                      . compatibility, we may not be able to guarantee that newer versions
  235.                      . of the code will be able to play older .DWM files.  In any event,
  236.                      . it's a good idea to always convert .MID files with the utility
  237.                      . which comes with the library you're linking into your application.
  238.                     */
  239.                     printf("DWS: Please reconvert this file using the MID2DWM.EXE\n");
  240.                     printf("     which came with this library\n");
  241.                     break;
  242.                 }
  243.                 case dws_MPlay_INTERNALERROR:
  244.                 {
  245.                     /*
  246.                      . This error should never occur and probably will not affect sound
  247.                      . play(?).  If it happens please contact DiamondWare.
  248.                     */
  249.                     printf("DWS: An internal error has occured\n");
  250.                     printf("     Please contact DiamondWare\n");
  251.                     break;
  252.                 }
  253.                 case dws_BUSY:
  254.                 {
  255.                     /*
  256.                      . Can only occur when DWS is being called from the background
  257.                      . (within an ISR--possibly timer or keyboard handler.)  If you get
  258.                      . this error, do your IRET, and call again from your next interrupt.
  259.                      . Repeat until successful.
  260.                     */
  261.                     printf("DWS: Busy now, please call again later.\n");
  262.                     break;
  263.                 }
  264.                 case dws_IRQDISABLED:
  265.                 {
  266.                  /*
  267.                     . The following error may be triggered by dws_Init, dws_Kill,
  268.                     . or dws_DetectHardWare.    It occurs if interrupts are disabled.
  269.                     . Enable interrupts (execute the STI instruction) and call again.
  270.                  */
  271.                     printf("DWS: Interrupts are disabled.\n");
  272.                     break;
  273.                 }
  274.                 #ifdef __FLAT__
  275.                 case dws_NOTRESIDENT:
  276.                 {
  277.                     /*
  278.                      . The real-mode STK component has not been installed, or
  279.                      . you may have mixed shareware & registerd versions.  The
  280.                      . solution is simple. Either STKRUN.EXE or run the correct
  281.                      . STKRUN.EXE.
  282.                     */
  283.                     printf("DWS: The STK driver is not resident, or you may be\n");
  284.                     printf("     mixing shareware and registered versions.\n");
  285.                     printf("     Registered libs are not compatible with the\n");
  286.                     printf("     shareware STKRUN.EXE, and vice versa.\n");
  287.                     break;
  288.                 }
  289.                 case dws_NOMEM:
  290.                 {
  291.                     /*
  292.                      . The following error will occur if the STK cannot allocate
  293.                      . enough DOS (real-mode) memory.
  294.                     */
  295.                     printf("DWS: Insufficient DOS memory.\n");
  296.                     break;
  297.                 }
  298.                 #endif
  299.                 default:
  300.                 {
  301.                     /*
  302.                      . If this function was clipped intact from err.c, this case
  303.                      . should never occur and probably will not affect sound play(?)
  304.                      . If it happens please contact DiamondWare.
  305.                     */
  306.                     printf("DWS: I'm confused!  Where am I?  HOW DID I GET HERE????\n");
  307.                     printf("     The ERROR number is: %d\n",errornum);
  308.                     break;
  309.                 }
  310.             }
  311.             break;
  312.         }
  313.         case err_DWDSP:
  314.         {
  315.             switch (errornum)
  316.             {
  317.                 case dwdsp_EZERO:
  318.                 {
  319.                     /*
  320.                      . This should not have happened, considering how we got here!
  321.                     */
  322.                     printf("DWDSP: I'm confused!  There is no error number!\n");
  323.                     break;
  324.                 }
  325.                 case dwdsp_NOTADWD:
  326.                 {
  327.                     /*
  328.                      . You passed DWDSP a pointer to something which is not a .DWD file!
  329.                     */
  330.                     printf("DWDSP: Pointer does not point to a .DWD\n");
  331.                     break;
  332.                 }
  333.                 case dwdsp_NULLPTR:
  334.                 {
  335.                     /*
  336.                      . You passed DWDSP a NULL pointer
  337.                     */
  338.                     printf("DWDSP: A NULL pointer was passed to a function.\n");
  339.  
  340.                     break;
  341.                 }
  342.                 case dwdsp_BADLEN:
  343.                 {
  344.                     /*
  345.                      . The length is smaller than the size of the DWD header.
  346.                      . There is no space for data!
  347.                     */
  348.                     printf("DWDSP: The length is too short to be useable.\n");
  349.                     break;
  350.                 }
  351.                 case dwdsp_SAMEPTR:
  352.                 {
  353.                     /*
  354.                      . This function does not support operation on
  355.                      . the source buffer.
  356.                     */
  357.                     printf("DWDSP: Can't use the same ptr.\n");
  358.                     break;
  359.                 }
  360.                 default:
  361.                 {
  362.                     /*
  363.                      . If this function was clipped intact from err.c, this case
  364.                      . should never occur.
  365.                     */
  366.                     printf("DWDSP: I'm confused!  Where am I?  HOW DID I GET HERE?\n");
  367.                     printf("       The ERROR number is: %d\n", errornum);
  368.                     break;
  369.                 }
  370.             }
  371.             break;
  372.         }
  373.         default:
  374.         {
  375.             printf("Unknown module specified!\n");
  376.         }
  377.     }
  378.  
  379.     /*
  380.      . If you are using a keyboard handler, the call to getch may cause a lockup
  381.     */
  382.     printf("\n\nPress any key to continue..\n\n");
  383.     getch();
  384. }
  385.